
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@include file="/common/headInclude.jsp" %>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>系统登录 - 超市账单管理系统</title>
    <link rel="stylesheet" href="${ctx}/statics/css/style.css"/>
    <script type="text/javascript">
        window.location.hash = "no-back";
        window.location.hash = "Again-No-back-button";
        window.onhashchange = function () {
            window.location.hash = "no-back";
        }
    </script>
</head>
<body class="login_bg">
<section class="loginBox">
    <header class="loginHeader">
        <h1>超市账单管理系统</h1>
        <div id="time" style="margin-left:390px;margin-top: 8px"></div>
    </header>
    <section class="loginCont">
        <form class="loginForm" id="myForm" method="post">
            <div class="inputbox">
                <label for="user">用户名：</label>
                <input id="user" type="text" name="userName" value="admin" placeholder="请输入用户名" required/>
            </div>
            <div class="inputbox">
                <label for="mima">密码：</label>
                <input id="mima" type="password" name="password" value="111" placeholder="请输入密码" required/>
            </div>
            <div class="subBtn">
                <input type="button" value="登录" id="btn"/>
                <input type="reset" value="重置"/>
            </div>

        </form>
    </section>
</section>
<script type="text/javascript">
    $(function () {
        $("#btn").click(function () {
            var flag1 = false;
            var flag2 = false;

            if ($("#user").val() == null || $("#user").val() == "") {
                alert("用户名不能为空！");
            } else {
                flag1 = true;
            }
            if ($("#mima").val() == null || $("#mima").val() == "") {
                alert("密码不能为空！");
            } else {
                flag2 = true;
            }
            if (flag1 && flag2) {
                var data = $("#myForm").serialize();
                //alert(data);
                $.post(
                    "${ctx}/user/userLogin",
                    data,
                    function (result) {
                        //alert("result------"+result);
                        /*常规登录方式*/
                        /*if (result==true) {
                            // alert(result.resMsg);
                            location.href = "
                        ${ctx}/user/login";
                        } else {
                            // alert(result.resCode);
                            alert("用户名或密码错误，请重新登录！");

                        }*/
                        /*shiro认证方式*/
                        if (result.resCode == "200") {
                            // alert(result.resMsg);
                            location.href = "${ctx}/user/login";
                        } else {
                            // alert(result.resCode);
                            alert(result.resMsg);

                        }
                    }, "json");
            } else {
                alert("请输入用户名和密码！");
            }

        });

    });

</script>

</body>
</html>